//
//  WalletHeaderView.swift
//  WalkNovel
//
//  Created by Kevin on 2023/7/10.
//

import UIKit

class WalletHeaderView: UIView {
    
    lazy var bgImage: UIImageView = {
        return UIImageView(image: UIImage(named: "setting_wallect_bg"))
    }()

    lazy var bgView: UIView = {
        let view = UIView()
        view.backgroundColor = .init(white: 1, alpha: 0.9)
        view.wn_cornerWithBorder(8)
        return view
    }()
    
    lazy var goldLabel: UILabel = {
        let label = UILabel()
        label.font = .wn_font(name: .bold, size: 13)
        label.textColor = .black
        label.textAlignment = .center
        label.text = "GOLD"
        return label
    }()
    
    lazy var headerImage: UIImageView = {
        let image = UIImageView()
        image.contentMode = .scaleAspectFill
        image.wn_cornerWithBorder(18)
        return image
    }()
    
    lazy var goldCount: UILabel = {
        let label = UILabel()
        label.font = .wn_font(name: .bold, size: 40)
        label.textColor = .black
        return label
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .white
        addSubview(bgImage)
        addSubview(bgView)
        bgView.addSubview(goldLabel)
        bgView.addSubview(headerImage)
        bgView.addSubview(goldCount)
        bgImage.snp.makeConstraints { make in
            make.top.left.right.equalTo(0)
            make.height.equalTo(scaleWidth(140))
        }
        bgView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(20)
            make.size.equalTo(CGSize.init(width: 335, height: 144))
        }
        goldLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(20)
        }
        headerImage.snp.makeConstraints { make in
            make.centerX.equalToSuperview().offset(-26)
            make.top.equalTo(goldLabel.snp.bottom).offset(20)
            make.height.width.equalTo(36)
        }
        goldCount.snp.makeConstraints { make in
            make.left.equalTo(headerImage.snp.right).offset(16)
            make.centerY.equalTo(headerImage.snp.centerY)
        }
        bgView.wn_cornerWithBorder(8, 0.1, .white, 1, .init(white: 0, alpha: 0.1), .zero, 8, 1)
        layer.masksToBounds = false
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
